package top.aicey.ai.sparring.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;

import top.aicey.ai.sparring.common.constants.TestConstants;
import top.aicey.ai.sparring.common.holder.SparringContext;
import top.aicey.ai.sparring.common.utils.BaseResponseUtil;
import top.aicey.ai.sparring.common.utils.UUIDUtils;
import top.aicey.ai.sparring.dto.enums.SparringStatusEnum;
import top.aicey.ai.sparring.dto.event.GenerateReportEvent;
import top.aicey.ai.sparring.dto.model.BaseResponse;
import top.aicey.ai.sparring.processor.SparringContextProcessorExecutor;

@RequestMapping("/v3/sparing/test/")
@RestController
public class AITestController {

    @Autowired
    private SparringContextProcessorExecutor sparringContextProcessorExecutor;


    @PostMapping("/report")
    public String testReport(@RequestBody String json) {
        GenerateReportEvent event = JSON.parseObject(json,GenerateReportEvent.class);

        return "success";
    }

    /**
     * 根据场景查询问答对
     *
     * @param
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/init/qa-pair")
    public BaseResponse<Long> resetQaPairs() {
        SparringContext context = new SparringContext();
        context.setAiAgentInstanceId("test1");
        context.setUserId(TestConstants.TEST_USER_ID);
        context.setModuleId(TestConstants.MODULE_ID);
        context.setSceneId(TestConstants.TEST_SCENE_ID);
        context.setPoint(0);
        context.setInstanceId(UUIDUtils.get32UUID());
        context.setStatus(SparringStatusEnum.ON_INIT);
        sparringContextProcessorExecutor.put(context);
        return BaseResponseUtil.buildSuccessResponse(context.getInstanceId());
    }


}
